#include "pagedisplaystrategyfactory.h"
#include "pagedisplaystrategy.h"
#include <QDebug>
PageDisplayStrategyFactory& PageDisplayStrategyFactory::instance()
{
    static PageDisplayStrategyFactory instance;
    return instance;
}
std::shared_ptr<PageDisplayStrategy> PageDisplayStrategyFactory::createStrategy(StrategyType type)
{
    switch (type) {
    case Simple:
        if (!m_simpleStrategy) {
            m_simpleStrategy = std::make_shared<SimpleDisplayStrategy>();
        }
        return m_simpleStrategy;
    case PageNumber:
        if (!m_pageNumberStrategy) {
            m_pageNumberStrategy = std::make_shared<PageNumberDisplayStrategy>();
        }
        return m_pageNumberStrategy;
    case Export:
        if (!m_exportStrategy) {
            m_exportStrategy = std::make_shared<ExportDisplayStrategy>();
        }
        return m_exportStrategy;
    default:
        return createStrategy(Simple);
    }
}
PageDisplayStrategyFactory::StrategyType PageDisplayStrategyFactory::selectStrategy(bool isExportMode, bool needsPageNumber)
{
    if (isExportMode) {
        return Export;
    } else if (needsPageNumber) {
        return PageNumber;
    } else {
        return Simple;
    }
}